package com.example.reactordemo.handler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;

/**
 * 页面访问请求路由配置
 */
@Configuration
public class RouterHandler {

    @Autowired
    private UserHandler userHandler;

    @Bean
    public RouterFunction route() {
        return RouterFunctions.route()
                .GET("/user",userHandler::findUsers)
                .GET("/user/{id}",userHandler::findUserById)
                .PUT("/user",userHandler::updateUserById)
                .POST("/user",userHandler::saveUser)
                .DELETE("/user/{id}",userHandler::deleteUserById).build();
    }
}
